package com.ihg.hiex.admin.dao.session;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Execute;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.during.SessionCalibration;
import com.ihg.hiex.entity.session.during.SessionCalibrationAnchorScore;
import com.ihg.hiex.entity.session.during.SessionCalibrationComment;
import com.ihg.hiex.entity.session.during.SessionCalibrationCompetency;
import com.ihg.hiex.entity.session.during.SessionCalibrationRecommendation;
import com.ihg.hiex.entity.user.Delegate;

/**
 * 
 * @author dan
 *
 */
@Dao("hibernate")
public interface SessionCalibrationDao {
    
    /**
     * 
     * @param session
     * @param delegateIds
     * @return
     */
    @Query("FROM SessionCalibration WHERE disabled = false AND session = :session AND delegate.id in (:delegateIds)")
    public List<SessionCalibration> listCalibration(@Variable("session") Session session, @Variable("delegateIds") List<Long> delegateIds);
    
    /**
     * 
     * @param sessionCalibrations
     * @return
     */
    @Query("FROM SessionCalibrationCompetency WHERE disabled = false AND sessionCalibration in (:sessionCalibrations) ORDER BY id ASC")
    public List<SessionCalibrationCompetency> listCompetency(@Variable("sessionCalibrations") List<SessionCalibration> sessionCalibrations);
    
    /**
     * 
     * @param sessionCalibration
     * @return
     */
    @Query("FROM SessionCalibrationCompetency WHERE disabled = false AND sessionCalibration = :sessionCalibration")
    public List<SessionCalibrationCompetency> listCompetency(@Variable("sessionCalibration") SessionCalibration sessionCalibration);
    
    /**
     * 
     * @param sessionCalibrations
     * @return
     */
    @Query("FROM SessionCalibrationComment WHERE disabled = false AND sessionCalibration in (:sessionCalibrations)")
    public List<SessionCalibrationComment> listComment(@Variable("sessionCalibrations") List<SessionCalibration> sessionCalibrations);
    
    /**
     * 
     * @param sessionCalibrations
     * @return
     */
    @Query("FROM SessionCalibrationRecommendation WHERE disabled = false AND sessionCalibration in (:sessionCalibrations)")
    public List<SessionCalibrationRecommendation> listRecommendation(@Variable("sessionCalibrations") List<SessionCalibration> sessionCalibrations);
    
    /**
     * 
     * @param sessionCalibration
     * @return
     */
    @Query("FROM SessionCalibrationRecommendation WHERE disabled = false AND sessionCalibration = :sessionCalibration")
    public List<SessionCalibrationRecommendation> listRecommendation(@Variable("sessionCalibration") SessionCalibration sessionCalibration);
    
    /**
     * 
     * @param sessionCalibration
     * @return
     */
    @Query("FROM SessionCalibrationRecommendation WHERE disabled = false AND sessionCalibration = :sessionCalibration")
    public SessionCalibrationRecommendation loadRecommendation(@Variable("sessionCalibration") SessionCalibration sessionCalibration);
    
    /**
     * 
     * @param sessionCalibrationCompetency
     * @return
     */
    @Query("FROM SessionCalibrationAnchorScore WHERE disabled = false AND competency = :sessionCalibrationCompetency")
    public List<SessionCalibrationAnchorScore> listAnchorScore(@Variable("sessionCalibrationCompetency") SessionCalibrationCompetency sessionCalibrationCompetency);
    
    /**
     * 
     * @param sessionCalibrationCompetencies
     * @return
     */
    @Query("FROM SessionCalibrationAnchorScore WHERE disabled = false AND competency in(:sessionCalibrationCompetency) AND (weak = true OR strong = true)")
    public List<SessionCalibrationAnchorScore> listAnchorScore(@Variable("sessionCalibrationCompetency") List<SessionCalibrationCompetency> sessionCalibrationCompetencies);
    
    /**
     * 
     * @param sessionCalibrationCompetencies
     * @return
     */
    @Query("FROM SessionCalibrationAnchorScore WHERE disabled = false AND competency in(:sessionCalibrationCompetency) AND strong = true")
    public List<SessionCalibrationAnchorScore> listStrongAnchorScores(@Variable("sessionCalibrationCompetency") List<SessionCalibrationCompetency> sessionCalibrationCompetencies);
    
    /**
     * 
     * @param sessionCalibrationCompetencies
     * @return
     */
    @Query("FROM SessionCalibrationAnchorScore WHERE disabled = false AND competency in(:sessionCalibrationCompetency) AND weak = true")
    public List<SessionCalibrationAnchorScore> listWeakAnchorScores(@Variable("sessionCalibrationCompetency") List<SessionCalibrationCompetency> sessionCalibrationCompetencies);
    
    /**
     * 
     * @param session
     * @param delegate
     * @return
     */
    @Query("FROM SessionCalibration WHERE disabled = false AND session = :session AND delegate = :delegate")
    public SessionCalibration loadCalibration(@Variable("session") Session session, @Variable("delegate") Delegate delegate);
    
    /**
     * 
     * @param sessionCalibration
     * @param name
     * @return
     */
    @Query("FROM SessionCalibrationCompetency WHERE disabled = false AND sessionCalibration = :sessionCalibration AND name = :name")
    public SessionCalibrationCompetency loadCompetency(@Variable("sessionCalibration") SessionCalibration sessionCalibration, @Variable("name") String name);
    
    /**
     * 
     * @param sessionCalibration
     */
    @Execute("UPDATE SessionCalibrationRecommendation SET disabled = true WHERE disabled = false AND sessionCalibration = :sessionCalibration")
    public void deleteRecommendation(@Variable("sessionCalibration") SessionCalibration sessionCalibration);
    
    /**
     * 
     * @param sessionCalibration
     * @return
     */
    @Query("FROM SessionCalibrationComment WHERE disabled = false AND sessionCalibration = :sessionCalibration")
    public SessionCalibrationComment loadComment(@Variable("sessionCalibration") SessionCalibration sessionCalibration);
    
}
